#include<iostream>
#include<vector>
#include<unordered_set>
#include<string>

using namespace std;

string int_to_string(int n)
{
    string s = to_string(n);
    ranges::sort(s);
    return s;
}

unordered_set<string> strs;

int init = []() {
    const int MAX_N = 1'000'000'000;
    for (int i = 1; i < MAX_N; i <<= 1) {
        string s = int_to_string(i);
        strs.insert(s);
    }
    return 0;
    }();

class Solution {
public:
    bool reorderedPowerOf2(int n) {
        string s = int_to_string(n);
        return strs.contains(s);
    }
};